<?php
/**
 * 广告管理
 *
 * @package         YDCMS
 * @author          QQ:644157559 <644157559@qq.com>
 * @version         $Id: MyadService.class.php v1.0 2014-06-13 17:27:03 $
 */
namespace Admin\Service;
class MyadService extends CommonService{
    
    /**
     * 数据入库
     * @param type $data
     * @return type
     */
    public function add($data) {
        $MyadModel = $this->getD();
        if(false === ($myad = $MyadModel->create($data))){
            return $this->errorResultReturn($MyadModel->getError());
        }
        if(false === $MyadModel->add($myad)){
            return $this->errorResultReturn("系统繁忙！");
        }
        
        return $this->resultReturn(TRUE);
    }
    
    /**
     * 更新数据
     * @param type $data
     * @return type
     */
    public function update($data) {
        $MyadModel = $this->getD();
        if(false === ($myad = $MyadModel->create($data))){
            return $this->errorResultReturn($MyadModel->getError());
        }
        if(false === $MyadModel->save($myad)){
            return $this->errorResultReturn("系统繁忙！");
        }
        
        return $this->resultReturn(TRUE);
    }
    
    /**
     * 删除
     * @param type $aid
     * @return type
     */
    public function delete($aid) {
        return $this->getM()->where(array('aid' => $aid))->delete();
    }
    /**
     * 根据ID获取数据
     * @param type $id
     * @return type
     */
    public function getById($id) {
        return $this->getM()->getByAid($id);
    }
    protected function getModelName() {
        return "Myad";
    }
}
